package com.scalar.chiptrack.operations.dataentry.rmaDisposition.actions;

import com.scalar.chiptrack.ChipTrackAction;
import com.scalar.chiptrack.operations.dataentry.rmaDisposition.actioncommands.RMADispositionActionCommandFactory;
import com.scalar.chiptrack.actioncommands.ActionCommand;
import com.scalar.chiptrack.commons.SessionKeys;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;

/**
 * User: ChandraSekhar
 * Date: Aug 22, 2008
 * Time: 1:51:33 PM
 */
public class RMADispositionAction extends ChipTrackAction implements SessionKeys
{
    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception
    {
        HashMap errors = new HashMap();
        request.setAttribute(ERROR_MESSAGES, errors);
        ActionForward actionForward;
        String action = request.getParameter("action");

        try
        {
            ActionCommand rmaDispositionCmd;
            rmaDispositionCmd = RMADispositionActionCommandFactory.getActionCommand( action );
            actionForward   = rmaDispositionCmd.execute( mapping, form, request, response );
        }
        catch (Exception e)
        {
            errors.put("Unable to load the Customers in RMA Disposition Screen", null);
            actionForward = mapping.findForward("rmaDisposition");
        }
        return actionForward;
    }
}